<template >
  <el-dialog title="题目预览" width="50%" >
    <div class="contan" slot="footer">
      <!-- 试题 提醒顶部区域-->
      <el-row class="rowspan">
        <el-col :span="6">
          <span>【题型】:{{datas.questionType==1? '单选':'双选'}}</span>
          <span>【学科】:{{datas.subjectName}}</span>
        </el-col>
        <el-col :span="6">
          <span>【编号】:{{datas.id}}</span>
          <span>【目录】:{{datas.directoryName}}</span>
        </el-col>
        <el-col :span="6">
          <span>【难度】:{{datas.difficulty}}</span>
          <span>【方向】:{{datas.direction}}</span>
        </el-col>
        <el-col :span="6">
          <span>【标签】:{{datas.tags}}</span>
        </el-col>
      </el-row>
      <hr />
      <!-- 题干区域 -->
      <div class="tigan">
        <div>
          <p>【题干】</p>
        </div>
        <div>
          <p class="blue" v-html="datas.question"></p>
        </div>
        <div>
          <p>{{datas.questionType}}题 {{datas.questionType!=='简答'?'选项:(以下选中的选项为正确答案)':''}}</p>
        </div>
        <div class="buttom radio" v-if="datas.questionType==='1'">
          <el-radio-group v-model="radio" @change="changeRadio">
            <el-radio
              :label="item.isRight"
              v-for="item in option"
              :key="item.id"
              style="display:block;lineHight:30px"
            >{{item.title}}</el-radio>
          </el-radio-group>
          <!-- 多选矿 -->
          <div v-if="datas.questionType==='2'" class="checkbox">
            <el-checkbox-group v-model="checkList" @change="changeRadio">
              <el-checkbox
                :label="item.isRight"
                v-for="item in option"
                :key="item.id"
                style="display:block;lineHight:30px"
              >{{item.title}}</el-checkbox>
            </el-checkbox-group>
          </div>
        </div>
        <span class="border"></span>
        <div class="buttom">
          <p>【参考答案】：<span v-html="datas.answer"></span></p>
        </div>
        <span class="border"></span>
        <div class="buttoms">
          <p>
            【答案解析】：
            <span>
              <el-tag type="danger" class="tag" @click="openVideo">视屏答案预览</el-tag>
            </span>
              <div v-if="isShow">
        <!-- 视频播放 -->
        <video height="200px" width="300px" preload="meta" controls="controls">
          <source :src="datas.videoURL" type="video/mp4" />
        </video>
      </div>
          </p>
        </div>
        <span class="border"></span>
        <div>
          <p>【题目备注】：{{datas.remarks}}</p>
        </div>
      </div>
      <span class="buttonspan">
        <el-button type="primary" @click="close">关闭</el-button>
      </span>
    </div>
  </el-dialog>
</template>

<script>
import { detail } from '@/api/hmmm/questions'// 获取数据列表
export default {


  name: 'tanchuang',
  props: {
    isdtilogdata: {
      type: [Object, Array, Boolean, String],
      required: true
    },
    isdtilog: {
      type: [Boolean],
      required: true
    },
  },
  data() {
    return {
      radio: 1,
      datas: [],// 数据
      checkList: [1],
      option: [],
      isShow: false
    }
  },
  components: {},
  watch: {
    value (newValue) {
      console.log(newValue)
      this.isdtilog = newValue
    },
    scope () {
      this.getdatas()
    }
  },
  created() {
    if (this.isdtilogdata) {
      this.getdatas() // 判断是否有数据源在进行请求新的数据
    }
  },
  mounted() { },
  methods: {
    // 关闭弹窗儿子传父亲
    close() {
      this.$emit('close', false)
       this.isShow = false
    },
    async getdatas() {
      try {
        const { data } = await detail()
        console.log(data, '0000000000000000')
        this.$message.success('成功')
        this.datas = data
          this.option = data.options
      } catch (error) {
      /*   this.$message('失败稍后再试...') */
      }
    },
    changeRadio(value) {
      this.radio = 1
      this.checkList = [1]
    },
    openVideo() {
      if (this.datas.videoURL) {
        this.isShow = true
      }
    }
  }
}
</script>

<style scoped lang="less">
.contan {
  .buttoms {
    margin: 10px 0 10px 0;
    position: relative;
    .tag {
      position: absolute;
      top: 10px;
      right: -110px;
      color: #fff;
      background-color: #f78989;
    }
  }
  .border {
    width: 100%;
    border-bottom: 1px solid #9a9a9a;
  }
  .buttonspan {
    display: flex;
    justify-content: flex-end;
  }
  font-size: 15px;
  color: #606266;

  span {
    display: flex;
    justify-content: space-around;
  }
  .tigan {
    .blue {
      color: blue;
      margin: -5px 0 -5px 0;
    }
    display: flex;
    align-items: start;
    flex-direction: column;
    .radio {
      .checkbox {
        .el-checkbox {
          margin-bottom: 10px;
        }
        display: flex;
        flex-direction: column;
      }
      text-align: left;
      margin-bottom: 10px;
      .el-radio {
        margin-bottom: 15px;
      }
    }

    .el-radio-group {
      display: flex;
      flex-direction: column;
      justify-content: start;
    }
  }
  .rowspan {
    margin-top: 20px;
    margin-bottom: 5px;
    span {
      margin-bottom: 15px;
    }
  }
}
</style>

